import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';

@Component({
  selector: 'app-result-confirm',
  templateUrl: './result-confirm.component.html',
  styleUrls: ['./result-confirm.component.scss']
})
export class ResultConfirmComponent implements OnInit {
  @Input()
  testItem: any = {};
  @Output()
  startEvent = new EventEmitter();

  progress = 0;
  playProgress = 0;
  progressInfo: any = '';
  passed: any;
  result: { passed: 'Y' | 'N', info: string } = {passed: 'Y', info: ''};

  constructor() {
  }

  ngOnInit(): void {
  }

  startRecording(): void {
    this.progress = 0;
    this.playProgress = 0;
    this.progressInfo = '录音中。。。';
    this.startEvent.emit();
    const interval = setInterval(() => {
      this.progress += 1;
      if (this.progress === 100) {
        this.progressInfo = '播放录音中。。。';
        this.progress = 0;

        const interval2 = setInterval(() => {
          this.progress += 1;
          if (this.progress === 100) {
            this.progressInfo = '音频测试完成';
            clearInterval(interval2);
          }
        }, 100);
        clearInterval(interval);
      }
    }, 100);
  }

}
